package com.ruoyi.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SuperBalanceDetail;
import com.ruoyi.system.service.ISuperBalanceDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 余额明细Controller
 * 
 * @author ruoyi
 * @date 2025-08-16
 */
@RestController
@RequestMapping("/balanceDetail/balanceDetail")
public class SuperBalanceDetailController extends BaseController
{
    @Autowired
    private ISuperBalanceDetailService superBalanceDetailService;

    /**
     * 查询余额明细列表
     */
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuperBalanceDetail superBalanceDetail)
    {
        startPage();
        List<SuperBalanceDetail> list = superBalanceDetailService.selectSuperBalanceDetailList(superBalanceDetail);
        return getDataTable(list);
    }

    /**
     * 导出余额明细列表
     */
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:export')")
    @Log(title = "余额明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SuperBalanceDetail superBalanceDetail)
    {
        List<SuperBalanceDetail> list = superBalanceDetailService.selectSuperBalanceDetailList(superBalanceDetail);
        ExcelUtil<SuperBalanceDetail> util = new ExcelUtil<SuperBalanceDetail>(SuperBalanceDetail.class);
        util.exportExcel(response, list, "余额明细数据");
    }

    /**
     * 获取余额明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(superBalanceDetailService.selectSuperBalanceDetailById(id));
    }

    /**
     * 新增余额明细
     */
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:add')")
    @Log(title = "余额明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuperBalanceDetail superBalanceDetail)
    {
        return toAjax(superBalanceDetailService.insertSuperBalanceDetail(superBalanceDetail));
    }

    /**
     * 修改余额明细
     */
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:edit')")
    @Log(title = "余额明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuperBalanceDetail superBalanceDetail)
    {
        return toAjax(superBalanceDetailService.updateSuperBalanceDetail(superBalanceDetail));
    }

    /**
     * 删除余额明细
     */
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:remove')")
    @Log(title = "余额明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(superBalanceDetailService.deleteSuperBalanceDetailByIds(ids));
    }

    // 根据用户id获取余额明细
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:list')")
    @GetMapping("/getUserId/{userId}")
    public TableDataInfo getUserId(@PathVariable("userId") Long userId)
    {
        startPage();
        List<SuperBalanceDetail> list = superBalanceDetailService.getUserId(userId);
        return getDataTable(list);
    }

    // 根据用户id获取余额充值明细
    @PreAuthorize("@ss.hasPermi('balanceDetail:balanceDetail:list')")
    @GetMapping("/getUserIdIncrease/{userId}")
    public TableDataInfo getUserIdIncrease(@PathVariable("userId") Long userId)
    {
        startPage();
        List<SuperBalanceDetail> list = superBalanceDetailService.getUserIdIncrease(userId);
        return getDataTable(list);
    }

}
